package com.lbn.monitor.app.home;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lbn.monitor.R;
import com.lbn.monitor.app.history.HistoryActivity;
import com.lbn.monitor.app.monitor.FacilityActivity;
import com.lbn.monitor.app.monitor.MFListActivity;
import com.lbn.monitor.app.warning.WarningActivity;
import com.lbn.monitor.base.AppBaseFragment;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class HomeFragment extends AppBaseFragment<HomePresenter> implements IHomeView {


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, null, false);
        ButterKnife.bind(this, view);
        return view;
    }


    @Override
    public HomePresenter createPresenter() {
        return new HomePresenter();
    }

    @Override
    protected void onPresenterCreated() {
        super.onPresenterCreated();
    }

    public static HomeFragment newInstance() {

        Bundle args = new Bundle();

        HomeFragment fragment = new HomeFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @OnClick({R.id.monitor, R.id.history, R.id.warning, R.id.patrol, R.id.min_data, R.id.hour_data})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.monitor:
                MFListActivity.startActivity(getContext(), 0);
                break;
            case R.id.history:
                HistoryActivity.startActivity(getContext(),2);
                break;
            case R.id.warning:
                WarningActivity.startActivity(getContext());
                break;
            case R.id.patrol:
                showToast("敬请期待");
                break;
            case R.id.min_data:
                HistoryActivity.startActivity(getContext(),0);
                break;
            case R.id.hour_data:
                HistoryActivity.startActivity(getContext(),1);
                break;
        }
    }
}
